home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / emacs16d.zip / RMAIL.MIN < prev    next >
Text File  |  1992-02-15  |  11KB  |  509 lines

  1. To do:
  2.     Improve address parser so that it knows about <>, and real names.
  3.  
  4.  
  5.  
  6. Name:Rfilename
  7. RFC 822 mailer routines.  Internally, we keep a list of mail messages
  8. numbered from one to N.  The current message is stored in ##(rmail-current).
  9. The list is stored as ##(rmail.<number>).  The contents of the list are
  10. the file number that the message is stored in.  If the first character
  11. of the file number is 'D', the message is deleted.
  12. [*]rmail[*]
  13.  
  14.  
  15. Name:R-mail-separator
  16. [*]--text follows this line--
  17. [*]
  18.  
  19.  
  20. Name:R-mail-queue
  21. [*]c:\spool\mqueue[*]
  22.  
  23.  
  24. Name:R-mail-spool
  25. [*]c:\spool\mail[*]
  26.  
  27.  
  28. Name:R-user
  29. Your user name.
  30. [*]jv[*]
  31.  
  32.  
  33. Name:R-reply
  34. The account that replies to your mail should be sent to.
  35. [*]nelson@sun.soe.clarkson.edu[*]
  36.  
  37.  
  38. Name:R-host
  39. The host name of this computer.
  40. [*]pear.ecs.clarkson.edu[*]
  41.  
  42.  
  43. Name:R-mail-host
  44. The name of a host with a smart mailer.  We bounce all mail to them.
  45. [*]omnigate.clarkson.edu[*]
  46.  
  47.  
  48. Name:R-time-zone
  49. Current time zone.  Should be EST, CST, MST, or PST, or GMT[+-]0000 as per
  50. RFC 822.  As currently set, you can also define an environment variable
  51. called 'TZ'.
  52. [*]#(n?,env.TZ,(#(env.TZ)),EST)[*]
  53.  
  54.  
  55. Name:F!R:rmail
  56. [*][*]
  57.  
  58.  
  59. Name:F!R:mail
  60. [*][*]
  61.  
  62.  
  63. Name:R:rmail
  64. Create the rmail buffer.
  65. [*]#(Fremember-buffer)
  66. #(Ffind-or-make-buffer,RMAIL)
  67. #(R:RMAIL-mode)
  68. #(Rrmail-get)
  69. #(ds,rmail-current,1)
  70. #(Rrmail-load)
  71. [*]
  72.  
  73.  
  74. Name:R:RMAIL-mode
  75. [*]#(Fexit-mode)
  76. #(Flocal-bind-key,K.n,R:rmail-next)
  77. #(Flocal-bind-key,K.p,R:rmail-prev)
  78. #(Flocal-bind-key,K.q,R:rmail-quit)
  79. #(Flocal-bind-key,K.r,R:rmail-reply)
  80. #(Flocal-bind-key,K.e,R:rmail-expunge)
  81. #(Flocal-bind-key,K.>,R:rmail-last)
  82. #(Flocal-bind-key,K.m,R:mail)
  83. #(Flocal-bind-key,K.d,R:rmail-delete)
  84. #(Flocal-bind-key,K.C-d,R:rmail-delete-and-prev)
  85. #(Flocal-bind-key,K.?,R:rmail-help)
  86. #(Fmv,Fself-insert,F!self-insert)
  87. #(Fmv,Rrmail-insert,Fself-insert)
  88. #(ds,mode-line-mode,( ##(rmail-current)/##(rmail-last)))
  89. #(ds,local-mode-changes,##(local-mode-changes)(
  90.     #(es,mode-line-mode)
  91.     #(Fmv,Fself-insert,Rrmail-insert)
  92.     #(Fmv,F!self-insert,Fself-insert)
  93. ))
  94. #(Fset-modename,RMAIL)
  95. [*]
  96.  
  97.  
  98. Name:R:rmail-help
  99. Not all of these are implemented.
  100. [*]
  101. #(ds,temp,(
  102. RMAIL Mode:
  103. Rmail Mode is used by M-x rmail for editing Rmail files.
  104. All normal editing commands are turned off.
  105. Instead, these commands are available:
  106.  
  107. .    Move point to front of this message (same as ESC <).
  108. SPC    Scroll to next screen of this message.
  109. DEL    Scroll to previous screen of this message.
  110. n    Move to Next non-deleted message.
  111. p    Move to Previous non-deleted message.
  112. M-n    Move to Next message whether deleted or not.
  113. M-p    Move to Previous message whether deleted or not.
  114. >    Move to the last message in Rmail file.
  115. j    Jump to message specified by numeric position in file.
  116. M-s    Search for string and show message it is found in.
  117. d    Delete this message, move to next nondeleted.
  118. C-d    Delete this message, move to previous nondeleted.
  119. u    Undelete message.  Tries current message, then earlier messages
  120.     till a deleted message is found.
  121. e    Expunge deleted messages.
  122. s    Expunge and save the file.
  123. q       Quit Rmail: expunge, save, then switch to another buffer.
  124. C-x C-s Save without expunging.
  125. g    Move new mail from system spool directory or mbox into this file.
  126. m    Mail a message (same as C-x 4 m).
  127. c    Continue composing outgoing message started before.
  128. r    Reply to this message.  Like m but initializes some fields.
  129. f    Forward this message to another user.
  130. o       Output this message to an Rmail file (append it).
  131. C-o    Output this message to a Unix-format mail file (append it).
  132. i    Input Rmail file.  Run Rmail on that file.
  133. a    Add label to message.  It will be displayed in the mode line.
  134. k    Kill label.  Remove a label from current message.
  135. C-M-n   Move to Next message with specified label
  136.           (label defaults to last one specified).
  137.           Standard labels: filed, unseen, answered, forwarded, deleted.
  138.           Any other label is present only if you add it with `a'.
  139. C-M-p   Move to Previous message with specified label
  140. C-M-h    Show headers buffer, with a one line summary of each message.
  141. C-M-l    Like h only just messages with particular label(s) are summarized.
  142. C-M-r   Like h only just messages with particular recipient(s) are summarized.
  143. t    Toggle header, show Rmail header if unformatted or vice versa.
  144. w    Edit the current message.  C-c C-c to return to Rmail.))
  145. #(mp,temp,,(
  146. ))
  147. #(Fmore)
  148. [*]
  149.  
  150.  
  151. Name:Rrmail-find-msg
  152. Find the "next" message starting at arg1.  If there is a next message,
  153. return arg3, otherwise arg4.  If arg5 is empty, skip deleted messages.
  154. [*]#(n?,rmail.arg1,(
  155.     #(==,##(--,##(rmail.arg1),##(rmail.arg1)),D0arg5,(
  156.         #(SELF,#(arg2,arg1,1),(arg2),(arg3),(arg4),arg5)
  157.     ),(
  158.         #(ds,rmail-current,arg1)
  159.         arg3
  160.     ))
  161. ),(
  162.     arg4
  163. ))[*]
  164.  
  165.  
  166. Name:R:rmail-next
  167. Moves to the next mail message.
  168. [*]#(Rrmail-find-msg,#(++,##(rmail-current),1),++,(
  169.     #(Rrmail-load)
  170. ),(
  171.     #(Fmessage,No more unread messages)
  172. ))[*]
  173.  
  174.  
  175. Name:R:rmail-prev
  176. [*]#(Rrmail-find-msg,#(--,##(rmail-current),1),--,(
  177.     #(Rrmail-load)
  178. ),(
  179.     #(Fmessage,No previous messages)
  180. ))[*]
  181.  
  182.  
  183. Name:R:rmail-delete
  184. [*]#(ds,rmail.##(rmail-current),D##(rmail.##(rmail-current)))
  185. #(R:rmail-next)[*]
  186.  
  187.  
  188. Name:R:rmail-undelete
  189. [*]#(==,##(go,rmail.##(rmail-current)),D,(
  190.     #(ds,rmail.##(rmail-current),##(rmail.##(rmail-current)))
  191. ),(
  192.     #(rs,rmail.##(rmail-current))
  193. ))[*]
  194.  
  195.  
  196. Name:R:rmail-delete-and-prev
  197. [*]#(ds,rmail.##(rmail-current),D##(rmail.##(rmail-current)))
  198. #(R:rmail-prev)[*]
  199.  
  200.  
  201. Name:R:rmail-quit
  202. [*]#(R:rmail-expunge)
  203. #(Freturn-to-buffer)[*]
  204.  
  205.  
  206. Name:R:rmail-expunge
  207. Remove all deleted messages.
  208. [*]#(Rrmail-expunge-do,1,1)
  209. #(Rrmail-load)[*]
  210.  
  211.  
  212. Name:Rrmail-expunge-do
  213. Arg1 is the input message.  Arg2 is the output message.  If arg1 is empty,
  214. then we are cleaning up the remaining input messages.
  215. [*]#(==,arg1,,(
  216.     #(n?,rmail.arg2,(
  217.         #(es,rmail.arg2)
  218.         #(SELF,,##(++,arg2,1))
  219.     ),(
  220.         #(ds,rmail-last,#(Rrmail-last))
  221.         #(g?,##(rmail-current),##(rmail-last),(
  222.             #(ds,rmail-current,##(rmail-last))
  223.         ))
  224.     ))
  225. ),(
  226.     #(n?,rmail.arg1,(
  227.         #(==,##(rmail-current),arg1,(
  228.             #(ds,rmail-current,arg2)
  229.         ))
  230.         #(ds,rmail.arg2,##(rmail.arg1))
  231.         #(SELF,##(++,arg1,1),
  232.             #(==,##(--,##(rmail.arg1),##(rmail.arg1)),D0,(
  233.                 arg2
  234.             ),(
  235.                 ##(++,arg2,1)
  236.             ))
  237.         )
  238.     ),(
  239.         #(SELF,,arg2)
  240.     ))
  241. ))[*]
  242.  
  243.  
  244. Name:R:rmail-reply
  245. [*]#(pm,3)
  246. #(lp,\n\n,,r)
  247. #(l?,[,],0,,,(
  248.     #(sm,0,])
  249. ))
  250. #(ds,from,#(RFC822-fetch-field,From))
  251. #(ds,subject,#(RFC822-fetch-field,Subject))
  252. #(pm)
  253. #(F:mail,(##(from)),(##(subject)))
  254. [*]
  255.  
  256.  
  257. ##(sa,##(ff,##(R-mail-spool)\##(R-user).*,(,)))
  258. #(Fread-file,/config.sys)
  259. #(Fsearch-path,movemail)
  260.  
  261.  
  262. Name:R:rmail-last
  263. Go to the last message.
  264. [*]#(ds,rmail-current,#(Rrmail-last))
  265. #(Rrmail-load)[*]
  266.  
  267.  
  268. Name:Rrmail-last
  269. Find the last message.
  270. [*]#(==,arg1,,(
  271.     #(SELF,1)
  272. ),(
  273.     #(n?,rmail.##(++,arg1,1),(
  274.         #(SELF,##(++,arg1,1))
  275.     ),(
  276.         arg1
  277.     ))
  278. ))[*]
  279.  
  280.  
  281. Name:Rrmail-get
  282. Get mail from the spool area.
  283. [*]#(ex,#(Fsearch-path,movemail),##(R-mail-spool)\##(R-user),,\rmail.out,\rmail.err)
  284. #(ds,temp,#(Fread-file,\rmail.err))
  285. #(==,##(temp),,,(
  286.     #(Ferror,Cannot get new mail: ##(temp))
  287. ))
  288. #(es,#(ls,(,),rmail.))
  289. #(ds,rmail-current,0)
  290. #(Fmultiple,Rrmail-get-do,##(sa,##(ff,##(R-mail-spool)\##(R-user).*,(,))),SELF)
  291. #(ds,rmail-last,#(Rrmail-last))
  292. #(de,\rmail.out)
  293. #(de,\rmail.err)
  294. [*]
  295.  
  296.  
  297. Name:Rrmail-get-do
  298. Insert a mail message into the rmail list IFF it's actually a mail file.
  299. Mail messages have numeric extensions.
  300. [*]#(g?,##(++,arg1,1),1,(
  301.     #(ds,rmail-current,##(++,##(rmail-current),1))
  302.     #(ds,rmail.##(rmail-current),
  303.         #(ds,temp,arg1)
  304.         #(..,##(fm,temp,.))
  305.         ##(temp)
  306.     )
  307. ))[*]
  308.  
  309. ##(rmail.1)
  310.  
  311. Name:Rrmail-load
  312. Load the mail file whose number is in rmail-current.  If arg1 is empty, strip
  313. any "useless" fields.
  314. [*]
  315. #(sp,[)
  316. #(dm,])
  317. #(rf,##(R-mail-spool)\##(R-user).##(rmail.##(rmail-current)))
  318. #(sp,[)
  319. #(pm,3)
  320. #(lp,\n\n,,r)
  321. #(l?,[,],0,,,(
  322.     #(sm,0,])
  323. ))
  324. #(==,arg1,,(
  325.     #(RFC822-strip-field,Received)
  326.     #(RFC822-strip-field,Message-Id)
  327. ))
  328. #(sv,mb,0)
  329. #(pm)
  330. [*]
  331.  
  332.  
  333. Name:RFC822-strip-field
  334. Search between [ and 0 for the RFC822 field in arg1.
  335. [*]#(lp,^arg1:,,r,i)
  336. #(l?,[,0,1,,(
  337.     #(sp,1)
  338.     #(dm,$)
  339.     #(dm,>)
  340.     #(SELF-do)
  341.     #(SELF,arg1)
  342. ))[*]
  343.  
  344. Name:RFC822-strip-field-do
  345. Strip successive RFC fields.
  346. [*]#(Fwhitespace,(
  347.     #(dm,$)
  348.     #(dm,>)
  349.     #(SELF)
  350. ),,x)[*]
  351.  
  352.  
  353. Name:RFC822-fetch-field
  354. Search between [ and 0 for the RFC822 field in arg1.
  355. [*]#(lp,^arg1:,,r,i)
  356. #(sp,0)
  357. #(l?,[,0,,1,(
  358.     #(sp,1)
  359.     #(Fforward-skip-white)
  360.     ##(rm,$)
  361. ))[*]
  362.  
  363.  
  364. Name:Rrmail-insert
  365. [*]#(bl)[*]
  366.  
  367.  
  368. ---------------------------- mail mode follows ----------------------------
  369.  
  370.  
  371. Name:K.C-x 4 m
  372. [*]R:mail-other-window[*]
  373.  
  374.  
  375. Name:K.C-x m
  376. [*]R:mail[*]
  377.  
  378.  
  379. Name:R:mail
  380. Create the mail buffer.  Use arg1 as the To: field and arg2 as the Subject: field.
  381. [*]#(Fremember-buffer)
  382. #(Ffind-or-make-buffer,*mail*)
  383. #(pm,1)
  384. #(is,To: arg1)
  385. #(Fcrlf)
  386. #(sm,0,<)
  387. #(is,Subject: arg2)
  388. #(Fcrlf)
  389. #(==,#(R-reply),,,(
  390.     #(is,Reply-to: #(R-reply))
  391.     #(Fcrlf)
  392. ))
  393. #(is,##(R-mail-separator))
  394. #(R:Mail-mode)
  395. #(sp,0)
  396. #(pm)
  397. [*]
  398.  
  399.  
  400. Name:R:mail-send
  401. Send the mail and bury the buffer.
  402. Bugs:
  403.     Needs to quote "\n.\n".
  404. [*]#(sp,[)
  405. #(pm,2)
  406. #(lp,^##(R-mail-separator),,r)
  407. #(l?,[,],0,1,(
  408.     #(lp,^Cc: ,,r,i)
  409.     #(ds,temp,
  410.         #(l?,[,1,,0,(
  411.             #(sp,0)
  412.             ##(rm,$)(,)
  413.         ))
  414.     )
  415.     #(lp,^To: ,,r,i)
  416.     #(l?,[,1,,0,(
  417.         #(sp,0)
  418.         #(ds,temp,##(temp)##(rm,$)(,))
  419.         #(mp,temp,, )
  420.         #(sp,[)
  421.         #(Fmultiple,Rmail-send,##(temp,(,)),SELF)
  422.         #(Freturn-to-buffer,n)
  423.     ),(
  424.         #(Ferror,No recipients specified!)
  425.     ))
  426. ),(
  427.     #(Ferror,Text separator not found!)
  428. ))
  429. #(pm)
  430. [*]
  431.  
  432.  
  433. Name:Rmail-send
  434. Called with arg1 = user to mail it to.
  435. [*]#(an,Mailing to arg1...)
  436. #(Fexcurse-buffer,(
  437.     #(Ffind-or-make-buffer,*mail-temporary*)
  438.     #(rf,#(R-mail-queue)\sequence.seq)
  439.     #(is,#(++,##(rm,[)#(dm,[),1))
  440.     #(ds,sequence.seq,##(rm,[))
  441.     #(wf,#(R-mail-queue)\sequence.seq,[)
  442.     #(sp,[)
  443.     #(dm,])
  444.  
  445.     #(bi,##(old-buffer),])
  446.     #(sp,[)
  447.     #(is,Date: #(RFC822-date))
  448.     #(Fcrlf)
  449.     #(is,Message-Id: <##(sequence.seq)@##(R-host)>)
  450.     #(Fcrlf)
  451.     #(is,From: ##(R-user)@##(R-host))
  452.     #(Fcrlf)
  453.     #(pm,2)
  454.     #(lp,^##(R-mail-separator),,r)
  455.     #(l?,[,],0,1,(
  456.         #(sp,0)
  457.         #(dm,1)
  458.         #(Fcrlf)
  459.         #(sp,[)
  460.         #(wf,#(R-mail-queue)\##(sequence.seq).txt,])
  461.         #(ds,temp,arg1)
  462.         #(..,##(fm,temp,@,(
  463.             #(ds,temp,arg1@##(R-host))
  464.             #(..,##(fm,temp,@))
  465.         )))
  466.         #(sp,[)
  467.         #(dm,])
  468.         #(is,#(==,##(R-mail-host),,(##(temp)),(##(R-mail-host))))
  469.         #(Fcrlf)
  470.         #(is,##(R-user)@##(R-host))
  471.         #(Fcrlf)
  472.         #(rs,temp)
  473.         #(is,##(temp))
  474.         #(Fcrlf)
  475.         #(wf,#(R-mail-queue)\##(sequence.seq).wrk,[)
  476.     ),(
  477.         #(Ferror,Text separator not found!)
  478.     ))
  479.     #(pm)
  480.     #(Fkill-buffer)
  481. ))[*]
  482.  
  483.  
  484. Name:R:Mail-mode
  485. [*]#(Fexit-mode)
  486. #(Flocal-bind-key,K.C-c C-c,R:mail-send)
  487. #(Fset-modename,Mail)
  488. [*]
  489.  
  490.  
  491. Name:RFC822-date
  492. #(RFC822-date) should be something like (Sat, 12 Nov 88 19:49:57 EST)
  493. [*]#(ds,temp,#(ct))
  494. #(mp,temp,, )
  495. #(SELF-do,#(temp,(,)))[*]
  496.  
  497.  
  498. Name:RFC822-date-do
  499. Sat,Nov,12,19:41:04,1988
  500. [*]#(ds,temp,arg5)
  501. #(..,##(gn,temp,2))
  502. arg1(, )arg3 arg2 ##(temp) arg4 #(R-time-zone)[*]
  503.  
  504.  
  505. Name:Fautoload-R
  506. [*]rmail[*]
  507.  
  508.  
  509.